/**
 * 地区表
 * @author platform
 * @email 15909910367@163.com
 * @date 2022-11-09 20:51:06
 */
Ext.define('Jason.view.protal.module.systemManager.sources.area.MainView',{
	extend : 'Ext.tree.Panel',
	alternateClassName: 'sysAreaView',
	itemId:'sysAreaView',
	alias: 'sysAreaView',
	requires : [
		'Wys.basic.BaseView',
		'Jason.store.protal.module.systemManager.souces.area.AreaModel',
		'Jason.store.protal.module.systemManager.sources.area.TreeStore',
		'Jason.view.protal.module.systemManager.sources.area.MainCtrl',
		'Jason.view.protal.module.systemManager.sources.area.MainViewModel'
	],
	viewModel : {type:'sysArea_ViewModel'},
	bind : '{areaTreeStore}',
	controller:'sysAreaViewCtrl',
	// selType: 'checkboxmodel',
	// multiSelect: true,
	enabledMark:false,
	dockedItems : [{
		xtype : 'toolbar',
		dock : 'top',
		items : [
			{xtype : 'segmentedbutton',
				items:[{
					xtype : 'newbutton',
					rightCode : 'QHGL'
				}]
			},
	    	"->",{xtype:'refresh',viewItemId  : '#sysAreaView'}
		]
	}],
	columns : [
		//如果是时间，请使用：xtype: 'datecolumn',format:'Y-m-d H:i'进行转换
		//如果是字典，请使用：xtype:'dictColumn',dicType:'字典类型'
		{text: 'ID',flex: 1, sortable: true,dataIndex: 'id',align: 'left',hidden:true},
		{xtype: 'treecolumn',text:'全名',dataIndex:'label',flex:.3},
		{text:'区划代码',dataIndex:'code',width:135},
		{text:'名称',dataIndex:'fullName',flex:.2},
		{text:'排序',dataIndex:'sortValue',width:60},
		{text:'经度',dataIndex:'longitude',width:120},
		{text:'维度',dataIndex:'latitude',width:120},
		{text:'区域等级',dataIndex:'level',width:80,renderer:function(v){
			//1-省 2-市 3-区县 4-街道镇
			if(v === '1') return '省';
			if(v === '2') return '市';
			if(v === '3') return '区县';
			if(v === '4') return '街道镇';
		}},
		{text:'来源',dataIndex:'source',width:100,renderer:function(v){
			return v?v:"系统录入";
		}},
		{text:'创建时间',dataIndex:'createDate',xtype: 'datecolumn',format:'Y-m-d H:i',width:130},
		{
            xtype: 'command',
            text: '操作',
            align: 'center',
            width: 140,
            commands: [
                {hidden:true, command: "modify", text: '编辑', tooltip: { text: '编辑' }, cls: 'radiusBtn a-text-success' },
                {hidden:true, command: "add", text: "添加", tooltip: { text: '添加' }, cls: 'radiusBtn a-text-success' },
                {hidden:true, command: "remove", text: "删除", tooltip: { text: '删除' }, cls: 'radiusBtn a-text-danger' }
            ],
            prepareCommand: function(grid,commands,record,row){
            	var command = commands.command;
				if(command === 'modify'){
					if(cfg.sub.accountPriview.indexOf('QHGL_EDIT') != -1){
						commands.hidden=false;
					}
				}
				if(command === 'add' && cfg.sub.accountPriview.indexOf('QHGL_SAVE') != -1){
					commands.hidden=false;
				}
				if(command === 'remove' && cfg.sub.accountPriview.indexOf('QHGL_DELETED') != -1){
					commands.hidden=false;
				}
		    },
            listeners: {
                command: 'onGridCommand'
            }
        }
	]
});